package com.allen.excelUtils.row;

import java.util.Iterator;
import java.util.Map;

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;

import com.allen.excelUtils.column.Column;
import com.allen.excelUtils.column.ColumnMapping;


public class DataRowImpl implements DataRow {
	private Row row;
	private ColumnMapping mapping;
	
	public DataRowImpl(Row row,ColumnMapping mapping){
		this.row = row;
		this.mapping = mapping;
	}
	
	@Override
	public Iterator<Cell> cellIterator() {
		return row.cellIterator();
	}

	@Override
	public Cell createCell(int arg0) {
		return row.createCell(arg0);
	}

	@Override
	public Cell createCell(int arg0, int arg1) {
		return row.createCell(arg0, arg1);
	}

	@Override
	public Cell getCell(int arg0) {
		return row.getCell(arg0);
	}

	@Override
	public Cell getCell(int arg0, MissingCellPolicy arg1) {
		return row.getCell(arg0, arg1);
	}

	@Override
	public short getFirstCellNum() {
		return row.getFirstCellNum();
	}

	@Override
	public short getHeight() {
		return row.getHeight();
	}

	@Override
	public float getHeightInPoints() {
		return row.getHeightInPoints();
	}

	@Override
	public short getLastCellNum() {
		
		return row.getLastCellNum();
	}

	@Override
	public int getPhysicalNumberOfCells() {
		return row.getPhysicalNumberOfCells();
	}

	@Override
	public int getRowNum() {
		return row.getRowNum();
	}

	@Override
	public CellStyle getRowStyle() {
		return row.getRowStyle();
	}

	@Override
	public Sheet getSheet() {
		return row.getSheet();
	}

	@Override
	public boolean getZeroHeight() {
		return row.getZeroHeight();
	}

	@Override
	public boolean isFormatted() {
		return row.isFormatted();
	}

	@Override
	public void removeCell(Cell arg0) {
		row.removeCell(arg0);
	}

	@Override
	public void setHeight(short arg0) {
		row.setHeight(arg0);
	}

	@Override
	public void setHeightInPoints(float arg0) {
		row.setHeightInPoints(arg0);
	}

	@Override
	public void setRowNum(int arg0) {
		row.setRowNum(arg0);
	}

	@Override
	public void setRowStyle(CellStyle arg0) {
		row.setRowStyle(arg0);
	}

	@Override
	public void setZeroHeight(boolean arg0) {
		row.setZeroHeight(arg0);
	}

	@Override
	public Iterator<Cell> iterator() {
		return row.iterator();
	}

	@Override
	public Cell getCell(String name)throws IndexOutOfBoundsException {
		int index = mapping.getColumnIndexByName(name);
		if (index<0) {
			throw new IndexOutOfBoundsException("不存在名称为"+name+"的列");
		}
		return row.getCell(index);
	}

	@Override
	public Row getRow() {
		return row;
	}

	@Override
	public Map<String, Column> getColumnMap() {
		return mapping.getColMap();
	}

}
